using System;
using System.Data;
using System.Data.SqlClient;
using SystemFrameworks;
using Common;
using DataAccess;
using Microsoft.ApplicationBlocks.Data;

namespace BusinessRules
{
    public class SigPlanPrograma
    {
        private const String SPZ_ID_PARAM = "@SPZ_ID";
        private const String PRG_ID_PARAM = "@PRG_ID";
        private const String PRG_CANTIDAD_PARAM = "@PRG_CANTIDAD";
        private const String PRG_DESCRIPCION_PARAM = "@PRG_DESCRIPCION";
        private const String GPR_ID_PARAM = "@GPR_ID";
        private const String PRG_OBSERVACIONES_PARAM = "@PRG_OBSERVACIONES";
        private const String PRG_VALOR_EJECUCION_PARAM = "@PRG_VALOR_EJECUCION";
        private const String PRG_POBLACION_BENEFICIADA_PARAM = "@PRG_POBLACION_BENEFICIADA";
        private const String ZON_ID_PARAM = "@ZON_ID";
        private const String RES_ID_PARAM = "@RES_ID";
        private const String PER_ID_PARAM = "@PER_ID";
        
        


        
        //private const String ZON_PADRE_ID_PARAM = "@ZON_PADRE_ID";
        //private const String ACC_ID_PARAM = "@ACC_ID";



        private string _CadenaConexion;

        public string CadenaConexion
        {
            get { return _CadenaConexion; }
            set { _CadenaConexion = value; }
        }
        public SigPlanPrograma(string strCadenaConecxion)
        {
            CadenaConexion = strCadenaConecxion;
        }

        //public SigPlanProgramaData ConsultarPlanProgramaZonPadreID(String strZonPadreId)
        //{
        //    SqlParameter param1 = strZonPadreId == "0" ? new SqlParameter(ZON_PADRE_ID_PARAM, System.DBNull.Value) : new SqlParameter(ZON_PADRE_ID_PARAM, strZonPadreId);

        //    SqlParameter[] parameters = { param1 };
        //    SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
        //    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_PLAN_PROGRAMA_ZON_PADRE_ID", objSigPlanProgramaData, parameters);
        //    return objSigPlanProgramaData;
        //}

        //public SigPlanProgramaData BuscarPlanProgramaTodos()
        //{
        //    SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
        //    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_BUSCAR_SIG_PLAN_PROGRAMA", objSigPlanProgramaData);
        //    return objSigPlanProgramaData;
        //}
        //public SigPlanProgramaData ConsultarPlanProgramaZonID(String strZonPadreId,String strZonId)
        //{
        //    SqlParameter param1 = new SqlParameter(ZON_PADRE_ID_PARAM, strZonPadreId);
        //    SqlParameter param2 = strZonId == "0" ? new SqlParameter(ZON_ID_PARAM, System.DBNull.Value) : new SqlParameter(ZON_ID_PARAM, strZonId);

        //    SqlParameter[] parameters = { param1,param2 };
        //    SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
        //    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_PLAN_PROGRAMA_ZON_ID", objSigPlanProgramaData, parameters);
        //    return objSigPlanProgramaData;
        //}

        public SigPlanProgramaData ConsultarPlanProgramaGprId(String strGprID, string strPerID)
        {
            SqlParameter param1 = new SqlParameter(GPR_ID_PARAM, strGprID);
            SqlParameter param2 = new SqlParameter(PER_ID_PARAM, strPerID);

            SqlParameter[] parameters = { param1, param2 };
            SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_PLAN_PROGRAMA_GPR_ID", objSigPlanProgramaData, parameters);
            return objSigPlanProgramaData;
        }

        public SigPlanProgramaData ConsultarPlanProgramaPerId(string strPerID)
        {
            
            SqlParameter param1 = new SqlParameter(PER_ID_PARAM, strPerID);

            SqlParameter[] parameters = { param1};
            SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_PLAN_PROGRAMA_PER_ID", objSigPlanProgramaData, parameters);
            return objSigPlanProgramaData;
        }


        public SigPlanProgramaData ConsultarPlanProgramaPerIdPublico(string strPerID)
        {

            SqlParameter param1 = new SqlParameter(PER_ID_PARAM, strPerID);

            SqlParameter[] parameters = { param1 };
            SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_PLAN_PROGRAMA_PER_ID_PUBLICO", objSigPlanProgramaData, parameters);
            return objSigPlanProgramaData;
        }

        public SigPlanProgramaData BuscarPlanPrograma()
        {
            
            SigPlanProgramaData objSigPlanProgramaData = new SigPlanProgramaData();
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_BUSCAR_SIG_PLAN_PROGRAMA", objSigPlanProgramaData);
            return objSigPlanProgramaData;
        }

    }
}
